#include "Sr04.h"
#include "Arduino.h"

Sr04::Sr04(int FsPin, int JsPin)
{
    this->FsPin = FsPin;
    this->JsPin = JsPin;
}

float Sr04::GetDistance()
{
    digitalWrite(FsPin, LOW);
    delayMicroseconds(5);
    digitalWrite(FsPin, HIGH);
    delayMicroseconds(12);
    digitalWrite(FsPin, LOW);

    float value = pulseIn(JsPin, HIGH) * 0.01715;
    return value;
}
